/*************************************************************************
	> File Name: conf.h
	> Author: gyl
	> Mail: gyldeyx@qq.com
	> Created Time: Thu 21 Jan 2021 06:39:44 PM CST
 ************************************************************************/

#ifndef _CONF_H
#define _CONF_H

#include <string>
#include <unordered_map>

class Config {
public:
    Config(const char *pConfigFileName);
    ~Config();

    void setValue(const std::string &strKey, const std::string &strValue);
    const char *getValue(std::string strKey) const;
    
private:
    void openConfigFile();
    void readConfigFile();//将配置读到内存中
    void writeConfigFile();//将内存中的数据写到配置文件中
    void closeConfigFile();

    char *removeSpace(char *strChar, size_t length);

private:

    std::unordered_map<std::string, std::string> m_mapKeyValue;

    std::string strConfigFileName; 
    FILE *m_pFp;
};

#endif
